//
//  T4ListModel.swift
//
//  Created by eme on 2017/4/10
//  Copyright (c) . All rights reserved.
//

import Foundation
import SwiftyJSON
import ModelProtocol

class T4ListModel: ModelProtocol {
    
    // MARK: Declaration for string constants to be used to decode and also serialize.
    internal let kT4ListMinagpriceKey: String = "shprice"
    internal let kT4ListPredateKey: String = "predate"
    internal let kT4ListImg1Key: String = "img1"
    internal let kT4ListPddesKey: String = "pddes"
    internal let kT4ListLmcountKey: String = "lmcount"
    internal let kT4ListBrnameKey: String = "brname"
    internal let kT4ListPdnameKey: String = "pdname"
    internal let kT4ListPdidKey: String = "pdid"
    internal let kT4ListIscolKey: String = "iscol"
    internal let kT4ListPrbdateKey: String = "prbdate"
    
    
    // MARK: 属性
    var minagprice: Double
    var predate: String
    var img1: String
    var pddes: String
    var lmcount: Int
    var brname: String
    var pdname: String
    var pdid: Int
    // 1表示收藏 0 表示未收藏
    var iscol: Int
    var prbdate: String
    /// 不等于3失效商品
    var pdstate:String
    var stock:Int
    var url:String
    var bdprice:Double
    
    // MARK: 实现MikerSwiftJSONAble 协议， 解析json数据
    public required  init?(json: JSON) {
        minagprice = json[kT4ListMinagpriceKey].doubleValue
        bdprice = json["bdprice"].doubleValue
        predate = json[kT4ListPredateKey].stringValue
        img1 = json[kT4ListImg1Key].stringValue
        pddes = json[kT4ListPddesKey].stringValue
        lmcount = json[kT4ListLmcountKey].intValue
        brname = json[kT4ListBrnameKey].stringValue
        pdname = json[kT4ListPdnameKey].stringValue
        pdid = json[kT4ListPdidKey].intValue
        iscol = json[kT4ListIscolKey].intValue
        prbdate = json[kT4ListPrbdateKey].stringValue
        pdstate = json["pdstate"].stringValue
        stock = json["stock"].intValue
        url = json["url"].stringValue
    }
    
    
    /**
     Generates description of the object in the form of a NSDictionary.
     - returns: A Key value pair containing all valid values in the object.
     */
    func dictionaryRepresentation() -> [String : AnyObject ] {
        
        var dictionary: [String : AnyObject ] = [ : ]
        
        dictionary.updateValue(minagprice as AnyObject, forKey: kT4ListMinagpriceKey)
        
        
        dictionary.updateValue(predate as AnyObject, forKey: kT4ListPredateKey)
        
        
        dictionary.updateValue(img1 as AnyObject, forKey: kT4ListImg1Key)
        
        
        dictionary.updateValue(pddes as AnyObject, forKey: kT4ListPddesKey)
        
        
        dictionary.updateValue(lmcount as AnyObject, forKey: kT4ListLmcountKey)
        
        
        dictionary.updateValue(brname as AnyObject, forKey: kT4ListBrnameKey)
        
        
        dictionary.updateValue(pdname as AnyObject, forKey: kT4ListPdnameKey)
        
        
        dictionary.updateValue(pdid as AnyObject, forKey: kT4ListPdidKey)
        
        
        dictionary.updateValue(iscol as AnyObject, forKey: kT4ListIscolKey)
        
        
        dictionary.updateValue(prbdate as AnyObject, forKey: kT4ListPrbdateKey)
        
        
        return dictionary
    }
    
    
}
